package com.skillworld.webapp.model.util;

public class Pagination 
{

    private int totalCount;
    private int pageSize;
    private int page;
    
    
    public Pagination(int totalCount, int pageSize, int page) 
    {
        this.totalCount = totalCount;
        this.pageSize = pageSize;
        this.page = page;
    }
    
    
    public int getTotalCount()
    {
        return totalCount;
    }

    public int getPageSize() 
    {
        return pageSize;
    }

    public int getPage()
    {
        return page;
    }


    public int getStartIndex()
    {
        return (page-1)*pageSize;
    }
    
    public int getCount()
    {
        return pageSize;
    }
    
    public int getNumberOfPages()
    {
        int val = totalCount/pageSize;
        
        val += ((totalCount%pageSize != 0) ||(val==0))?1:0; 
        
        return val;
    }
    
    public boolean isValidPage()
    {
        return page >= 1 && page <= this.getNumberOfPages(); 
    }
    
}
